package com.biwin.module.org.domain.entity;

import com.biwin.module.orm.api.entity.BwBasicEntity;

import javax.persistence.*;
import java.util.List;

/**
 * Organization 组织
 *
 * @author biwin
 * @since 0.0.1
 */
@Entity
@Table(name = "organization")
@org.hibernate.annotations.Table(appliesTo = "organization", comment = "组织表")
public class Organization extends BwBasicEntity {

    private static final long serialVersionUID = -4893507045598738109L;
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "parent_id", columnDefinition = " BIGINT(20) COMMENT '父级编号' ",
            foreignKey = @ForeignKey(value = ConstraintMode.NO_CONSTRAINT))
    private Organization parent;

    @Column(name = "name", columnDefinition = "VARCHAR(60) NOT NULL COMMENT '组织名称'")
    private String name;

    @Column(name = "org_no", columnDefinition = "VARCHAR(10) COMMENT '组织编码'")
    private String orgNo;

    @Column(name = "org_type", columnDefinition = "TINYINT(1) COMMENT '组织类型(0-机构,1-公司,2-部门,3-组)'")
    private Integer orgType;

    @Column(name = "org_level", columnDefinition = "INT NOT NULL DEFAULT 1 COMMENT '组织层级(1是顶级)'")
    private Integer orgLevel = 1;

    @Column(name = "org_person_count", columnDefinition = "INT NOT NULL DEFAULT 0 COMMENT '组织下总人数'")
    private Integer orgPersonCount = 0;

    @Column(name = "org_manager", columnDefinition = "BIGINT(20) COMMENT '组织负责人' ")
    private Long orgManager;

    @Column(name = "sort", columnDefinition = "INT NOT NULL DEFAULT 0 COMMENT '排序号(数值越大排名越高)'")
    private Integer sort = 0;

    @Column(name = "org_id_path", columnDefinition = "varchar(1024) comment '组织id路径'")
    private String orgIdPath;

    @Column(name = "org_name_path", columnDefinition = "varchar(1024) comment '组织名称路径'")
    private String orgNamePath;

    @Column(name = "org_no_path", columnDefinition = "varchar(1024) comment '组织编号路径'")
    private String orgNoPath;

    @Column(name = "enabled", columnDefinition = "BIT(1) NOT NULL DEFAULT B'1' COMMENT '组织是否有效'")
    private Boolean enabled = true;

    @Column(name = "leaf", columnDefinition = "BIT(1) NOT NULL DEFAULT B'0' COMMENT '是否是叶子节点(无下级节点)'")
    private Boolean leaf = true;

    public Organization getParent() {
        return parent;
    }

    public void setParent(Organization parent) {
        this.parent = parent;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getOrgNo() {
        return orgNo;
    }

    public void setOrgNo(String orgNo) {
        this.orgNo = orgNo;
    }

    public Integer getOrgType() {
        return orgType;
    }

    public void setOrgType(Integer orgType) {
        this.orgType = orgType;
    }

    public Integer getOrgLevel() {
        return orgLevel;
    }

    public void setOrgLevel(Integer orgLevel) {
        this.orgLevel = orgLevel;
    }

    public Integer getOrgPersonCount() {
        return orgPersonCount;
    }

    public void setOrgPersonCount(Integer orgPersonCount) {
        this.orgPersonCount = orgPersonCount;
    }

    public Long getOrgManager() {
        return orgManager;
    }

    public void setOrgManager(Long orgManager) {
        this.orgManager = orgManager;
    }

    public Integer getSort() {
        return sort;
    }

    public void setSort(Integer sort) {
        this.sort = sort;
    }

    public String getOrgIdPath() {
        return orgIdPath;
    }

    public void setOrgIdPath(String orgIdPath) {
        this.orgIdPath = orgIdPath;
    }

    public String getOrgNamePath() {
        return orgNamePath;
    }

    public void setOrgNamePath(String orgNamePath) {
        this.orgNamePath = orgNamePath;
    }

    public String getOrgNoPath() {
        return orgNoPath;
    }

    public void setOrgNoPath(String orgNoPath) {
        this.orgNoPath = orgNoPath;
    }

    public Boolean getEnabled() {
        return enabled;
    }

    public void setEnabled(Boolean enabled) {
        this.enabled = enabled;
    }

    public Boolean getLeaf() {
        return leaf;
    }

    public void setLeaf(Boolean leaf) {
        this.leaf = leaf;
    }

}
